<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>eCommerce: Plik źródłowy D:/CentrumXP/e-Commerce/eCommerceDev/SklepDAO/VoucherDAO.cs</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Wygenerowano przez Doxygen 1.6.1 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Szukaj');
--></script>
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Strona&nbsp;główna</span></a></li>
      <li><a href="namespaces.html"><span>Pakiety</span></a></li>
      <li><a href="annotated.html"><span>Klasy</span></a></li>
      <li class="current"><a href="files.html"><span>Pliki</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <img id="MSearchSelect" src="search/search.png"
             onmouseover="return searchBox.OnSearchSelectShow()"
             onmouseout="return searchBox.OnSearchSelectHide()"
             alt=""/>
        <input type="text" id="MSearchField" value="Szukaj" accesskey="S"
             onfocus="searchBox.OnSearchFieldFocus(true)" 
             onblur="searchBox.OnSearchFieldFocus(false)" 
             onkeyup="searchBox.OnSearchFieldChange(event)"/>
        <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
        </div>
      </li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>Lista&nbsp;plików</span></a></li>
      <li><a href="globals.html"><span>Składowe&nbsp;plików</span></a></li>
    </ul>
  </div>
<h1>D:/CentrumXP/e-Commerce/eCommerceDev/SklepDAO/VoucherDAO.cs</h1><a href="_voucher_d_a_o_8cs.html">Idź do dokumentacji tego pliku.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a><a class="code" href="_voucher_d_a_o_8cs.html#a81a223a02c34d82b47199f08308847f2">00001</a> ﻿using <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>;
<a name="l00002"></a>00002 <span class="keyword">using</span> <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Collections.Generic;
<a name="l00003"></a>00003 <span class="keyword">using</span> <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Text;
<a name="l00004"></a>00004 <span class="keyword">using</span> ShopModel;
<a name="l00005"></a>00005 <span class="keyword">using</span> <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Data;
<a name="l00006"></a>00006 <span class="keyword">using</span> <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Data.SqlClient;
<a name="l00007"></a>00007 
<a name="l00008"></a>00008 <span class="keyword">namespace </span>ShopDAO
<a name="l00009"></a>00009 {
<a name="l00010"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html">00010</a>     <span class="keyword">public</span> <span class="keyword">class </span><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html">VoucherDAO</a>
<a name="l00011"></a>00011     {
<a name="l00012"></a>00012         <span class="keyword">private</span> <span class="keywordtype">string</span> connectionString;
<a name="l00013"></a>00013 
<a name="l00014"></a>00014         <span class="keyword">private</span> SqlConnection Connection()
<a name="l00015"></a>00015         {
<a name="l00016"></a>00016             <span class="keywordflow">return</span> <span class="keyword">new</span> SqlConnection(connectionString);
<a name="l00017"></a>00017         }
<a name="l00018"></a>00018 
<a name="l00019"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#aa7efce189aae62d4d74b381f1bc43164">00019</a>         <span class="keyword">public</span> <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#aa7efce189aae62d4d74b381f1bc43164">VoucherDAO</a>()
<a name="l00020"></a>00020         {
<a name="l00021"></a>00021             connectionString = <a class="code" href="_common_tools_8cs.html#a81a223a02c34d82b47199f08308847f2">System</a>.Configuration.ConfigurationManager.ConnectionStrings[<span class="stringliteral">&quot;csShop&quot;</span>].ConnectionString;
<a name="l00022"></a>00022         }
<a name="l00023"></a>00023 
<a name="l00036"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a9a6f0b5328a65a988266e02171a8ff3b">00036</a>         <span class="keyword">public</span> List&lt;Voucher&gt; <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a9a6f0b5328a65a988266e02171a8ff3b" title="Pobiera informacje o kuponach rabatowych kupującego. (Gets information about the...">GetCustomerVouchers</a>(<span class="keywordtype">int</span> CustomerId)
<a name="l00037"></a>00037         {
<a name="l00038"></a>00038             SqlConnection sqlC = Connection();
<a name="l00039"></a>00039             SqlCommand command = sqlC.CreateCommand();
<a name="l00040"></a>00040             SqlDataReader sqlR;
<a name="l00041"></a>00041             List&lt;Voucher&gt; result = <span class="keyword">new</span> List&lt;Voucher&gt;();
<a name="l00042"></a>00042 
<a name="l00043"></a>00043             command.CommandText = <span class="stringliteral">&quot;GetCustomerVouchers&quot;</span>;
<a name="l00044"></a>00044             command.CommandType = CommandType.StoredProcedure;
<a name="l00045"></a>00045 
<a name="l00046"></a>00046             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@CustomerId&quot;</span>, CustomerId));
<a name="l00047"></a>00047 
<a name="l00048"></a>00048             <span class="keywordflow">try</span>
<a name="l00049"></a>00049             {
<a name="l00050"></a>00050                 sqlC.Open();
<a name="l00051"></a>00051                 sqlR = command.ExecuteReader();
<a name="l00052"></a>00052                 <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> voucher = null;
<a name="l00053"></a>00053                 <span class="keywordflow">while</span> (sqlR.Read())
<a name="l00054"></a>00054                 {
<a name="l00055"></a>00055                     voucher = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a>();
<a name="l00056"></a>00056                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a909694a7b5b427da771c7455c5dbe9a2">IdVoucher</a> = (int)sqlR[<span class="stringliteral">&quot;IdVoucher&quot;</span>];
<a name="l00057"></a>00057                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ab923c696c57259546ace2b981aeab096">Code</a> = sqlR[<span class="stringliteral">&quot;Guid&quot;</span>].ToString().Replace(<span class="stringliteral">&quot;-&quot;</span>, <span class="stringliteral">&quot;&quot;</span>).Substring(0, 8);
<a name="l00058"></a>00058                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ab90fef9116bde0401095a0e741b15b31">Type</a> = (<a class="code" href="namespace_shop_model.html#acc81c893d7d36d8d9a5f9a48faab18cd">VoucherType</a>)sqlR[<span class="stringliteral">&quot;Type&quot;</span>];
<a name="l00059"></a>00059                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a93660a40a079fdf14d0a24b7c92308f3">Date</a> = (DateTime)sqlR[<span class="stringliteral">&quot;Date&quot;</span>];
<a name="l00060"></a>00060                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad895e7b80d3ba643ad47541fcbae43ce">Value</a> = (sqlR[<span class="stringliteral">&quot;Value&quot;</span>] == DBNull.Value) ? null : (decimal?)sqlR[<span class="stringliteral">&quot;Value&quot;</span>];
<a name="l00061"></a>00061                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a2039c9722cb6d086e95c4099544215ae">AcceptValue</a> = (decimal)sqlR[<span class="stringliteral">&quot;AcceptValue&quot;</span>];
<a name="l00062"></a>00062                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a9e0168c56bceccef26ddbad4d2f6ecaf">CustomerId</a> = (sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>];
<a name="l00063"></a>00063                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ac3dfc3d75d6147f29746f6c93dacfa3e">Used</a> = (bool)sqlR[<span class="stringliteral">&quot;Used&quot;</span>];
<a name="l00064"></a>00064                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad6d8fba639bc5fb9ed2bf951d55f2196">UsedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>];
<a name="l00065"></a>00065                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a9f491f855dee22285c93c9a504a907d8">GeneratedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>];
<a name="l00066"></a>00066                     result.Add(voucher);
<a name="l00067"></a>00067                 }
<a name="l00068"></a>00068 
<a name="l00069"></a>00069                 sqlR.Close();
<a name="l00070"></a>00070             }
<a name="l00071"></a>00071             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00072"></a>00072             {
<a name="l00073"></a>00073                 ErrorLogger.LogError(ex);
<a name="l00074"></a>00074             }
<a name="l00075"></a>00075             <span class="keywordflow">finally</span>
<a name="l00076"></a>00076             { sqlC.Close(); }
<a name="l00077"></a>00077 
<a name="l00078"></a>00078             <span class="keywordflow">return</span> result;
<a name="l00079"></a>00079         }
<a name="l00080"></a>00080 
<a name="l00093"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#ad6e0310a41e782865f00f361c1212a48">00093</a>         <span class="keyword">public</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#ad6e0310a41e782865f00f361c1212a48" title="Pobiera informacje o stworzonym kuponie rabatowym. (Gets information about the created...">GetGeneratedRealizationVoucher</a>(<span class="keywordtype">int</span> RealizationId)
<a name="l00094"></a>00094         {
<a name="l00095"></a>00095             SqlConnection sqlC = Connection();
<a name="l00096"></a>00096             SqlCommand command = sqlC.CreateCommand();
<a name="l00097"></a>00097             SqlDataReader sqlR;
<a name="l00098"></a>00098             <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> result = null;
<a name="l00099"></a>00099 
<a name="l00100"></a>00100             command.CommandText = <span class="stringliteral">&quot;GetGeneratedRealizationVoucher&quot;</span>;
<a name="l00101"></a>00101             command.CommandType = CommandType.StoredProcedure;
<a name="l00102"></a>00102 
<a name="l00103"></a>00103             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@RealizationId&quot;</span>, RealizationId));
<a name="l00104"></a>00104 
<a name="l00105"></a>00105             <span class="keywordflow">try</span>
<a name="l00106"></a>00106             {
<a name="l00107"></a>00107                 sqlC.Open();
<a name="l00108"></a>00108                 sqlR = command.ExecuteReader();
<a name="l00109"></a>00109                 <span class="keywordflow">if</span> (sqlR.Read())
<a name="l00110"></a>00110                 {
<a name="l00111"></a>00111                     result = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a>();
<a name="l00112"></a>00112                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a909694a7b5b427da771c7455c5dbe9a2">IdVoucher</a> = (int)sqlR[<span class="stringliteral">&quot;IdVoucher&quot;</span>];
<a name="l00113"></a>00113                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ab923c696c57259546ace2b981aeab096">Code</a> = sqlR[<span class="stringliteral">&quot;Guid&quot;</span>].ToString().Replace(<span class="stringliteral">&quot;-&quot;</span>, <span class="stringliteral">&quot;&quot;</span>).Substring(0, 8);
<a name="l00114"></a>00114                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ab90fef9116bde0401095a0e741b15b31">Type</a> = (<a class="code" href="namespace_shop_model.html#acc81c893d7d36d8d9a5f9a48faab18cd">VoucherType</a>)sqlR[<span class="stringliteral">&quot;Type&quot;</span>];
<a name="l00115"></a>00115                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a93660a40a079fdf14d0a24b7c92308f3">Date</a> = (DateTime)sqlR[<span class="stringliteral">&quot;Date&quot;</span>];
<a name="l00116"></a>00116                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ad895e7b80d3ba643ad47541fcbae43ce">Value</a> = (sqlR[<span class="stringliteral">&quot;Value&quot;</span>] == DBNull.Value) ? null : (decimal?)sqlR[<span class="stringliteral">&quot;Value&quot;</span>];
<a name="l00117"></a>00117                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a2039c9722cb6d086e95c4099544215ae">AcceptValue</a> = (decimal)sqlR[<span class="stringliteral">&quot;AcceptValue&quot;</span>];
<a name="l00118"></a>00118                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a9e0168c56bceccef26ddbad4d2f6ecaf">CustomerId</a> = (sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>];
<a name="l00119"></a>00119                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ac3dfc3d75d6147f29746f6c93dacfa3e">Used</a> = (bool)sqlR[<span class="stringliteral">&quot;Used&quot;</span>];
<a name="l00120"></a>00120                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ad6d8fba639bc5fb9ed2bf951d55f2196">UsedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>];
<a name="l00121"></a>00121                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a9f491f855dee22285c93c9a504a907d8">GeneratedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>];
<a name="l00122"></a>00122                 }
<a name="l00123"></a>00123                 sqlR.Close();
<a name="l00124"></a>00124             }
<a name="l00125"></a>00125             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00126"></a>00126             {
<a name="l00127"></a>00127                 ErrorLogger.LogError(ex);
<a name="l00128"></a>00128             }
<a name="l00129"></a>00129             <span class="keywordflow">finally</span>
<a name="l00130"></a>00130             { sqlC.Close(); }
<a name="l00131"></a>00131 
<a name="l00132"></a>00132             <span class="keywordflow">return</span> result;
<a name="l00133"></a>00133         }
<a name="l00134"></a>00134 
<a name="l00147"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#ad5537731df1d3d191bcd8aece3478815">00147</a>         <span class="keyword">public</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#ad5537731df1d3d191bcd8aece3478815" title="Pobiera informacje o wykorzystanym kuponie rabatowym. (Gets information about the...">GetUsedRealizationVoucher</a>(<span class="keywordtype">int</span> RealizationId)
<a name="l00148"></a>00148         {
<a name="l00149"></a>00149             SqlConnection sqlC = Connection();
<a name="l00150"></a>00150             SqlCommand command = sqlC.CreateCommand();
<a name="l00151"></a>00151             SqlDataReader sqlR;
<a name="l00152"></a>00152             <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> result = null;
<a name="l00153"></a>00153 
<a name="l00154"></a>00154             command.CommandText = <span class="stringliteral">&quot;GetUsedRealizationVoucher&quot;</span>;
<a name="l00155"></a>00155             command.CommandType = CommandType.StoredProcedure;
<a name="l00156"></a>00156 
<a name="l00157"></a>00157             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@RealizationId&quot;</span>, RealizationId));
<a name="l00158"></a>00158 
<a name="l00159"></a>00159             <span class="keywordflow">try</span>
<a name="l00160"></a>00160             {
<a name="l00161"></a>00161                 sqlC.Open();
<a name="l00162"></a>00162                 sqlR = command.ExecuteReader();
<a name="l00163"></a>00163                 <span class="keywordflow">if</span> (sqlR.Read())
<a name="l00164"></a>00164                 {
<a name="l00165"></a>00165                     result = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a>();
<a name="l00166"></a>00166                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a909694a7b5b427da771c7455c5dbe9a2">IdVoucher</a> = (int)sqlR[<span class="stringliteral">&quot;IdVoucher&quot;</span>];
<a name="l00167"></a>00167                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ab923c696c57259546ace2b981aeab096">Code</a> = sqlR[<span class="stringliteral">&quot;Guid&quot;</span>].ToString().Replace(<span class="stringliteral">&quot;-&quot;</span>, <span class="stringliteral">&quot;&quot;</span>).Substring(0, 8);
<a name="l00168"></a>00168                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ab90fef9116bde0401095a0e741b15b31">Type</a> = (<a class="code" href="namespace_shop_model.html#acc81c893d7d36d8d9a5f9a48faab18cd">VoucherType</a>)sqlR[<span class="stringliteral">&quot;Type&quot;</span>];
<a name="l00169"></a>00169                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a93660a40a079fdf14d0a24b7c92308f3">Date</a> = (DateTime)sqlR[<span class="stringliteral">&quot;Date&quot;</span>];
<a name="l00170"></a>00170                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ad895e7b80d3ba643ad47541fcbae43ce">Value</a> = (sqlR[<span class="stringliteral">&quot;Value&quot;</span>] == DBNull.Value) ? null : (decimal?)sqlR[<span class="stringliteral">&quot;Value&quot;</span>];
<a name="l00171"></a>00171                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a2039c9722cb6d086e95c4099544215ae">AcceptValue</a> = (decimal)sqlR[<span class="stringliteral">&quot;AcceptValue&quot;</span>];
<a name="l00172"></a>00172                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a9e0168c56bceccef26ddbad4d2f6ecaf">CustomerId</a> = (sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>];
<a name="l00173"></a>00173                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ac3dfc3d75d6147f29746f6c93dacfa3e">Used</a> = (bool)sqlR[<span class="stringliteral">&quot;Used&quot;</span>];
<a name="l00174"></a>00174                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ad6d8fba639bc5fb9ed2bf951d55f2196">UsedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>];
<a name="l00175"></a>00175                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a9f491f855dee22285c93c9a504a907d8">GeneratedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>];
<a name="l00176"></a>00176                 }
<a name="l00177"></a>00177                 sqlR.Close();
<a name="l00178"></a>00178             }
<a name="l00179"></a>00179             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00180"></a>00180             {
<a name="l00181"></a>00181                 ErrorLogger.LogError(ex);
<a name="l00182"></a>00182             }
<a name="l00183"></a>00183             <span class="keywordflow">finally</span>
<a name="l00184"></a>00184             { sqlC.Close(); }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186             <span class="keywordflow">return</span> result;
<a name="l00187"></a>00187         }
<a name="l00188"></a>00188 
<a name="l00205"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a6cf57868f34ccc37ead7f73ece94b949">00205</a>         <span class="keyword">public</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a6cf57868f34ccc37ead7f73ece94b949" title="Pobiera informacje o wybranym kuponie rabatowym. (Gets information about the selected...">GetVoucherByGuid</a>(<span class="keywordtype">string</span> VoucherCode, <span class="keywordtype">bool</span>? Used)
<a name="l00206"></a>00206         {
<a name="l00207"></a>00207             SqlConnection sqlC = Connection();
<a name="l00208"></a>00208             SqlCommand command = sqlC.CreateCommand();
<a name="l00209"></a>00209             SqlDataReader sqlR;
<a name="l00210"></a>00210             <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> result = null;
<a name="l00211"></a>00211 
<a name="l00212"></a>00212             command.CommandText = <span class="stringliteral">&quot;GetVoucherByGuid&quot;</span>;
<a name="l00213"></a>00213             command.CommandType = CommandType.StoredProcedure;
<a name="l00214"></a>00214 
<a name="l00215"></a>00215             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Code&quot;</span>, VoucherCode.Replace(<span class="stringliteral">&quot;-&quot;</span>, <span class="stringliteral">&quot;&quot;</span>).Substring(0, 8)));
<a name="l00216"></a>00216             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Used&quot;</span>, Used));
<a name="l00217"></a>00217 
<a name="l00218"></a>00218             <span class="keywordflow">try</span>
<a name="l00219"></a>00219             {
<a name="l00220"></a>00220                 sqlC.Open();
<a name="l00221"></a>00221                 sqlR = command.ExecuteReader();
<a name="l00222"></a>00222                 <span class="keywordflow">if</span> (sqlR.Read())
<a name="l00223"></a>00223                 {
<a name="l00224"></a>00224                     result = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a>();
<a name="l00225"></a>00225                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a909694a7b5b427da771c7455c5dbe9a2">IdVoucher</a> = (int)sqlR[<span class="stringliteral">&quot;IdVoucher&quot;</span>];
<a name="l00226"></a>00226                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ab923c696c57259546ace2b981aeab096">Code</a> = sqlR[<span class="stringliteral">&quot;Guid&quot;</span>].ToString().Replace(<span class="stringliteral">&quot;-&quot;</span>, <span class="stringliteral">&quot;&quot;</span>).Substring(0, 8);
<a name="l00227"></a>00227                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ab90fef9116bde0401095a0e741b15b31">Type</a> = (<a class="code" href="namespace_shop_model.html#acc81c893d7d36d8d9a5f9a48faab18cd">VoucherType</a>)sqlR[<span class="stringliteral">&quot;Type&quot;</span>];
<a name="l00228"></a>00228                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a93660a40a079fdf14d0a24b7c92308f3">Date</a> = (DateTime)sqlR[<span class="stringliteral">&quot;Date&quot;</span>];
<a name="l00229"></a>00229                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ad895e7b80d3ba643ad47541fcbae43ce">Value</a> = (sqlR[<span class="stringliteral">&quot;Value&quot;</span>] == DBNull.Value) ? null : (decimal?)sqlR[<span class="stringliteral">&quot;Value&quot;</span>];
<a name="l00230"></a>00230                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a2039c9722cb6d086e95c4099544215ae">AcceptValue</a> = (decimal)sqlR[<span class="stringliteral">&quot;AcceptValue&quot;</span>];
<a name="l00231"></a>00231                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a9e0168c56bceccef26ddbad4d2f6ecaf">CustomerId</a> = (sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>];
<a name="l00232"></a>00232                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ac3dfc3d75d6147f29746f6c93dacfa3e">Used</a> = (bool)sqlR[<span class="stringliteral">&quot;Used&quot;</span>];
<a name="l00233"></a>00233                     result.<a class="code" href="class_shop_model_1_1_voucher.html#ad6d8fba639bc5fb9ed2bf951d55f2196">UsedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>];
<a name="l00234"></a>00234                     result.<a class="code" href="class_shop_model_1_1_voucher.html#a9f491f855dee22285c93c9a504a907d8">GeneratedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>];
<a name="l00235"></a>00235                 }
<a name="l00236"></a>00236                 sqlR.Close();
<a name="l00237"></a>00237             }
<a name="l00238"></a>00238             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00239"></a>00239             {
<a name="l00240"></a>00240                 ErrorLogger.LogError(ex);
<a name="l00241"></a>00241             }
<a name="l00242"></a>00242             <span class="keywordflow">finally</span>
<a name="l00243"></a>00243             { sqlC.Close(); }
<a name="l00244"></a>00244 
<a name="l00245"></a>00245             <span class="keywordflow">return</span> result;
<a name="l00246"></a>00246         }
<a name="l00247"></a>00247 
<a name="l00260"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#ab48bc9a632fbf60dbc687654c7688258">00260</a>         <span class="keyword">public</span> <span class="keywordtype">int</span> <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#ab48bc9a632fbf60dbc687654c7688258" title="Zapisuje informacje o nowym kuponie rabatowym. (Saves information about the new discount...">SaveVoucher</a>(<a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a>)
<a name="l00261"></a>00261         {
<a name="l00262"></a>00262             SqlConnection sqlC = Connection();
<a name="l00263"></a>00263             SqlCommand command = sqlC.CreateCommand();
<a name="l00264"></a>00264             SqlDataReader sqlR;
<a name="l00265"></a>00265 
<a name="l00266"></a>00266             <span class="keywordtype">int</span> result = -1;
<a name="l00267"></a>00267 
<a name="l00268"></a>00268             command.CommandText = <span class="stringliteral">&quot;SaveVoucher&quot;</span>;
<a name="l00269"></a>00269             command.CommandType = CommandType.StoredProcedure;
<a name="l00270"></a>00270 
<a name="l00271"></a>00271             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@IdVoucher&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a909694a7b5b427da771c7455c5dbe9a2">IdVoucher</a>));
<a name="l00272"></a>00272             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Type&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ab90fef9116bde0401095a0e741b15b31">Type</a>));
<a name="l00273"></a>00273             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Date&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a93660a40a079fdf14d0a24b7c92308f3">Date</a>));
<a name="l00274"></a>00274             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@AcceptValue&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a2039c9722cb6d086e95c4099544215ae">AcceptValue</a>));
<a name="l00275"></a>00275             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@CustomerId&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a9e0168c56bceccef26ddbad4d2f6ecaf">CustomerId</a>));
<a name="l00276"></a>00276             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Used&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ac3dfc3d75d6147f29746f6c93dacfa3e">Used</a>));
<a name="l00277"></a>00277             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@GeneratedRealizationId&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a9f491f855dee22285c93c9a504a907d8">GeneratedRealizationId</a>));
<a name="l00278"></a>00278             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Value&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad895e7b80d3ba643ad47541fcbae43ce">Value</a>));
<a name="l00279"></a>00279             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@UsedRealizationId&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad6d8fba639bc5fb9ed2bf951d55f2196">UsedRealizationId</a>));
<a name="l00280"></a>00280 
<a name="l00281"></a>00281             <span class="keywordflow">try</span>
<a name="l00282"></a>00282             {
<a name="l00283"></a>00283                 sqlC.Open();
<a name="l00284"></a>00284                 sqlR = command.ExecuteReader();
<a name="l00285"></a>00285 
<a name="l00286"></a>00286                 <span class="keywordflow">if</span> (sqlR.Read())
<a name="l00287"></a>00287                     result = (<span class="keywordtype">int</span>)sqlR[<span class="stringliteral">&quot;VoucherID&quot;</span>];
<a name="l00288"></a>00288 
<a name="l00289"></a>00289                 sqlR.Close();
<a name="l00290"></a>00290             }
<a name="l00291"></a>00291             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00292"></a>00292             {
<a name="l00293"></a>00293                 ErrorLogger.LogError(ex);
<a name="l00294"></a>00294             }
<a name="l00295"></a>00295             <span class="keywordflow">finally</span>
<a name="l00296"></a>00296             { sqlC.Close(); }
<a name="l00297"></a>00297 
<a name="l00298"></a>00298             <span class="keywordflow">return</span> result;
<a name="l00299"></a>00299         }
<a name="l00300"></a>00300 
<a name="l00309"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a223375ae958a9cf2f2187b856052e14a">00309</a>         <span class="keyword">public</span> <span class="keywordtype">int</span>[] <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a223375ae958a9cf2f2187b856052e14a" title="Pobiera unikalne ID wszystkich rodzajów kuponów rabatowych z bazy. (Gets unique...">GetAllVoucherTypesIDs</a>()
<a name="l00310"></a>00310         {
<a name="l00311"></a>00311             List&lt;int&gt; result = null;
<a name="l00312"></a>00312             SqlConnection connection = Connection();
<a name="l00313"></a>00313             SqlCommand command = connection.CreateCommand();
<a name="l00314"></a>00314 
<a name="l00315"></a>00315             command.CommandText = <span class="stringliteral">&quot;GetAllVoucherTypesIDs&quot;</span>;
<a name="l00316"></a>00316             command.CommandType = CommandType.StoredProcedure;
<a name="l00317"></a>00317 
<a name="l00318"></a>00318             result = <span class="keyword">new</span> List&lt;int&gt;();
<a name="l00319"></a>00319             <span class="keywordflow">try</span>
<a name="l00320"></a>00320             {
<a name="l00321"></a>00321                 connection.Open();
<a name="l00322"></a>00322                 SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
<a name="l00323"></a>00323 
<a name="l00324"></a>00324                 <span class="keywordflow">while</span> (reader.Read())
<a name="l00325"></a>00325                 {
<a name="l00326"></a>00326                     result.Add(reader.GetInt32(0));
<a name="l00327"></a>00327                 }
<a name="l00328"></a>00328 
<a name="l00329"></a>00329                 reader.Close();
<a name="l00330"></a>00330             }
<a name="l00331"></a>00331             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00332"></a>00332             {
<a name="l00333"></a>00333                 ErrorLogger.LogError(ex);
<a name="l00334"></a>00334             }
<a name="l00335"></a>00335             <span class="keywordflow">finally</span>
<a name="l00336"></a>00336             { connection.Close(); }
<a name="l00337"></a>00337 
<a name="l00338"></a>00338             <span class="keywordflow">return</span> result.ToArray();
<a name="l00339"></a>00339         }
<a name="l00340"></a>00340 
<a name="l00349"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#ac634d63b4551e3dcb8f4d15dbacd7326">00349</a>         <span class="keyword">public</span> List&lt;Voucher&gt; <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#ac634d63b4551e3dcb8f4d15dbacd7326" title="Pobiera listę kuponów rabatowych (Downloads list of discount vouchers).">GetVouchers</a>(ref <span class="keywordtype">int</span> pageNumber, <span class="keywordtype">int</span> pageSize, out <span class="keywordtype">int</span> Count, <span class="keywordtype">bool</span> used)
<a name="l00350"></a>00350         {
<a name="l00351"></a>00351             <span class="keywordtype">string</span> query = <span class="keywordtype">string</span>.Empty;
<a name="l00352"></a>00352             SqlConnection sqlC = Connection();
<a name="l00353"></a>00353             SqlCommand command = sqlC.CreateCommand();
<a name="l00354"></a>00354             SqlDataReader sqlR;
<a name="l00355"></a>00355             List&lt;Voucher&gt; result = <span class="keyword">new</span> List&lt;Voucher&gt;();
<a name="l00356"></a>00356 
<a name="l00357"></a>00357             command.CommandText = <span class="stringliteral">&quot;GetVouchers&quot;</span>;
<a name="l00358"></a>00358             command.CommandType = CommandType.StoredProcedure;
<a name="l00359"></a>00359 
<a name="l00360"></a>00360             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@page_size&quot;</span>, pageSize));
<a name="l00361"></a>00361 
<a name="l00362"></a>00362             SqlParameter inout = <span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@page_number&quot;</span>, SqlDbType.Int);
<a name="l00363"></a>00363             inout.Direction = ParameterDirection.InputOutput;
<a name="l00364"></a>00364             inout.Value = pageNumber;
<a name="l00365"></a>00365             command.Parameters.Add(inout);
<a name="l00366"></a>00366 
<a name="l00367"></a>00367             SqlParameter output = <span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@vouchers_count&quot;</span>, SqlDbType.Int);
<a name="l00368"></a>00368             output.Direction = ParameterDirection.Output;
<a name="l00369"></a>00369             command.Parameters.Add(output);
<a name="l00370"></a>00370 
<a name="l00371"></a>00371             query = <span class="keywordtype">string</span>.Format(<span class="stringliteral">&quot;SELECT [IdVoucher],[Guid],[Type] ,[Date] ,[Value] ,[AcceptValue],[CustomerId],[Used] ,[GeneratedRealizationId],[UsedRealizationId] FROM [Vouchers] WHERE Used={0}&quot;</span>, used ? 1 : 0);
<a name="l00372"></a>00372 
<a name="l00373"></a>00373             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@query&quot;</span>, query));
<a name="l00374"></a>00374             <span class="keywordflow">try</span>
<a name="l00375"></a>00375             {
<a name="l00376"></a>00376                 sqlC.Open();
<a name="l00377"></a>00377                 sqlR = command.ExecuteReader();
<a name="l00378"></a>00378                 <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> voucher = null;
<a name="l00379"></a>00379                 <span class="keywordflow">while</span> (sqlR.Read())
<a name="l00380"></a>00380                 {
<a name="l00381"></a>00381                     voucher = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a>();
<a name="l00382"></a>00382                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a909694a7b5b427da771c7455c5dbe9a2">IdVoucher</a> = (int)sqlR[<span class="stringliteral">&quot;IdVoucher&quot;</span>];
<a name="l00383"></a>00383                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ab923c696c57259546ace2b981aeab096">Code</a> = sqlR[<span class="stringliteral">&quot;Guid&quot;</span>].ToString().Replace(<span class="stringliteral">&quot;-&quot;</span>, <span class="stringliteral">&quot;&quot;</span>).Substring(0, 8);
<a name="l00384"></a>00384                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ab90fef9116bde0401095a0e741b15b31">Type</a> = (<a class="code" href="namespace_shop_model.html#acc81c893d7d36d8d9a5f9a48faab18cd">VoucherType</a>)sqlR[<span class="stringliteral">&quot;Type&quot;</span>];
<a name="l00385"></a>00385                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a93660a40a079fdf14d0a24b7c92308f3">Date</a> = (DateTime)sqlR[<span class="stringliteral">&quot;Date&quot;</span>];
<a name="l00386"></a>00386                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad895e7b80d3ba643ad47541fcbae43ce">Value</a> = (sqlR[<span class="stringliteral">&quot;Value&quot;</span>] == DBNull.Value) ? null : (decimal?)sqlR[<span class="stringliteral">&quot;Value&quot;</span>];
<a name="l00387"></a>00387                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a2039c9722cb6d086e95c4099544215ae">AcceptValue</a> = (decimal)sqlR[<span class="stringliteral">&quot;AcceptValue&quot;</span>];
<a name="l00388"></a>00388                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a9e0168c56bceccef26ddbad4d2f6ecaf">CustomerId</a> = (sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>];
<a name="l00389"></a>00389                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ac3dfc3d75d6147f29746f6c93dacfa3e">Used</a> = (bool)sqlR[<span class="stringliteral">&quot;Used&quot;</span>];
<a name="l00390"></a>00390                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad6d8fba639bc5fb9ed2bf951d55f2196">UsedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>];
<a name="l00391"></a>00391                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a9f491f855dee22285c93c9a504a907d8">GeneratedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>];
<a name="l00392"></a>00392                     result.Add(voucher);
<a name="l00393"></a>00393                 }
<a name="l00394"></a>00394 
<a name="l00395"></a>00395                 sqlR.Close();
<a name="l00396"></a>00396 
<a name="l00397"></a>00397                 Count = (int)output.Value;
<a name="l00398"></a>00398                 pageNumber = (<span class="keywordtype">int</span>)inout.Value;
<a name="l00399"></a>00399             }
<a name="l00400"></a>00400             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00401"></a>00401             {
<a name="l00402"></a>00402                 ErrorLogger.LogError(ex);
<a name="l00403"></a>00403                 Count = 0;
<a name="l00404"></a>00404             }
<a name="l00405"></a>00405             <span class="keywordflow">finally</span>
<a name="l00406"></a>00406             { sqlC.Close(); }
<a name="l00407"></a>00407 
<a name="l00408"></a>00408             <span class="keywordflow">return</span> result;
<a name="l00409"></a>00409         }
<a name="l00410"></a>00410 
<a name="l00417"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a1aa3bfb04865e51b7eed1049b92cfb18">00417</a>         <span class="keyword">public</span> <span class="keywordtype">bool</span> <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a1aa3bfb04865e51b7eed1049b92cfb18" title="Tworzy nowy kupon rabatowy (Creates new discount voucher).">GenerateVouchers</a>(<a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a>,<span class="keywordtype">int</span> count)
<a name="l00418"></a>00418         {
<a name="l00419"></a>00419             SqlConnection sqlC = Connection();
<a name="l00420"></a>00420             SqlCommand command = sqlC.CreateCommand();
<a name="l00421"></a>00421 
<a name="l00422"></a>00422             command.CommandText = <span class="stringliteral">&quot;GenerateVouchers&quot;</span>;
<a name="l00423"></a>00423             command.CommandType = CommandType.StoredProcedure;
<a name="l00424"></a>00424 
<a name="l00425"></a>00425             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Count&quot;</span>, count));
<a name="l00426"></a>00426             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Type&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ab90fef9116bde0401095a0e741b15b31">Type</a>));
<a name="l00427"></a>00427             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@AcceptValue&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a2039c9722cb6d086e95c4099544215ae">AcceptValue</a>));
<a name="l00428"></a>00428             command.Parameters.Add(<span class="keyword">new</span> SqlParameter(<span class="stringliteral">&quot;@Value&quot;</span>, Voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad895e7b80d3ba643ad47541fcbae43ce">Value</a>));
<a name="l00429"></a>00429             <span class="keywordtype">bool</span> result = <span class="keyword">false</span>;
<a name="l00430"></a>00430             <span class="keywordflow">try</span>
<a name="l00431"></a>00431             {
<a name="l00432"></a>00432                 sqlC.Open();
<a name="l00433"></a>00433                 command.ExecuteNonQuery();
<a name="l00434"></a>00434                 result = <span class="keyword">true</span>;   
<a name="l00435"></a>00435             }
<a name="l00436"></a>00436             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00437"></a>00437             {
<a name="l00438"></a>00438                 ErrorLogger.LogError(ex);
<a name="l00439"></a>00439                 result = <span class="keyword">false</span>;
<a name="l00440"></a>00440             }
<a name="l00441"></a>00441             <span class="keywordflow">finally</span>
<a name="l00442"></a>00442             { sqlC.Close(); }
<a name="l00443"></a>00443 
<a name="l00444"></a>00444             <span class="keywordflow">return</span> result;
<a name="l00445"></a>00445 
<a name="l00446"></a>00446         }
<a name="l00447"></a>00447 
<a name="l00453"></a><a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a027fa974182a16c9f99de312e5519765">00453</a>         <span class="keyword">public</span> List&lt;Voucher&gt; <a class="code" href="class_shop_d_a_o_1_1_voucher_d_a_o.html#a027fa974182a16c9f99de312e5519765" title="Pobiera kupon rabatowy na podstawie jego ID (Downloads discount voucher on the basis...">GetVouchersByIDs</a>(<span class="keywordtype">string</span> IDs)
<a name="l00454"></a>00454         {
<a name="l00455"></a>00455             IDs = <a class="code" href="class_shop_d_a_o_1_1_customer_d_a_o.html">CustomerDAO</a>.CheckIntegerList(IDs);
<a name="l00456"></a>00456             <span class="keywordtype">string</span> query = <span class="keywordtype">string</span>.Empty;
<a name="l00457"></a>00457             SqlConnection sqlC = Connection();
<a name="l00458"></a>00458             SqlCommand command = sqlC.CreateCommand();
<a name="l00459"></a>00459             SqlDataReader sqlR;
<a name="l00460"></a>00460             List&lt;Voucher&gt; result = <span class="keyword">new</span> List&lt;Voucher&gt;();
<a name="l00461"></a>00461 
<a name="l00462"></a>00462             command.CommandText = <span class="keywordtype">string</span>.Format(<span class="stringliteral">&quot;SELECT [IdVoucher],[Guid],[Type] ,[Date] ,[Value] ,[AcceptValue],[CustomerId],[Used] ,[GeneratedRealizationId],[UsedRealizationId] FROM [Vouchers] WHERE IdVoucher IN ({0})&quot;</span>, IDs);
<a name="l00463"></a>00463 
<a name="l00464"></a>00464             <span class="keywordflow">try</span>
<a name="l00465"></a>00465             {
<a name="l00466"></a>00466                 sqlC.Open();
<a name="l00467"></a>00467                 sqlR = command.ExecuteReader();
<a name="l00468"></a>00468                 <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a> voucher = null;
<a name="l00469"></a>00469                 <span class="keywordflow">while</span> (sqlR.Read())
<a name="l00470"></a>00470                 {
<a name="l00471"></a>00471                     voucher = <span class="keyword">new</span> <a class="code" href="class_shop_model_1_1_voucher.html" title="Klasa opisująca Vouchera. (Class describing Voucher.).">Voucher</a>();
<a name="l00472"></a>00472                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a909694a7b5b427da771c7455c5dbe9a2">IdVoucher</a> = (int)sqlR[<span class="stringliteral">&quot;IdVoucher&quot;</span>];
<a name="l00473"></a>00473                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ab923c696c57259546ace2b981aeab096">Code</a> = sqlR[<span class="stringliteral">&quot;Guid&quot;</span>].ToString().Replace(<span class="stringliteral">&quot;-&quot;</span>, <span class="stringliteral">&quot;&quot;</span>).Substring(0, 8);
<a name="l00474"></a>00474                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ab90fef9116bde0401095a0e741b15b31">Type</a> = (<a class="code" href="namespace_shop_model.html#acc81c893d7d36d8d9a5f9a48faab18cd">VoucherType</a>)sqlR[<span class="stringliteral">&quot;Type&quot;</span>];
<a name="l00475"></a>00475                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a93660a40a079fdf14d0a24b7c92308f3">Date</a> = (DateTime)sqlR[<span class="stringliteral">&quot;Date&quot;</span>];
<a name="l00476"></a>00476                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad895e7b80d3ba643ad47541fcbae43ce">Value</a> = (sqlR[<span class="stringliteral">&quot;Value&quot;</span>] == DBNull.Value) ? null : (decimal?)sqlR[<span class="stringliteral">&quot;Value&quot;</span>];
<a name="l00477"></a>00477                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a2039c9722cb6d086e95c4099544215ae">AcceptValue</a> = (decimal)sqlR[<span class="stringliteral">&quot;AcceptValue&quot;</span>];
<a name="l00478"></a>00478                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a9e0168c56bceccef26ddbad4d2f6ecaf">CustomerId</a> = (sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;CustomerId&quot;</span>];
<a name="l00479"></a>00479                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ac3dfc3d75d6147f29746f6c93dacfa3e">Used</a> = (bool)sqlR[<span class="stringliteral">&quot;Used&quot;</span>];
<a name="l00480"></a>00480                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#ad6d8fba639bc5fb9ed2bf951d55f2196">UsedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;UsedRealizationId&quot;</span>];
<a name="l00481"></a>00481                     voucher.<a class="code" href="class_shop_model_1_1_voucher.html#a9f491f855dee22285c93c9a504a907d8">GeneratedRealizationId</a> = (sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>] == DBNull.Value) ? null : (<span class="keywordtype">int</span>?)sqlR[<span class="stringliteral">&quot;GeneratedRealizationId&quot;</span>];
<a name="l00482"></a>00482                     result.Add(voucher);
<a name="l00483"></a>00483                 }
<a name="l00484"></a>00484 
<a name="l00485"></a>00485                 sqlR.Close();
<a name="l00486"></a>00486             }
<a name="l00487"></a>00487             <span class="keywordflow">catch</span> (Exception ex)
<a name="l00488"></a>00488             {
<a name="l00489"></a>00489                 ErrorLogger.LogError(ex);
<a name="l00490"></a>00490             }
<a name="l00491"></a>00491             <span class="keywordflow">finally</span>
<a name="l00492"></a>00492             { sqlC.Close(); }
<a name="l00493"></a>00493 
<a name="l00494"></a>00494             <span class="keywordflow">return</span> result; 
<a name="l00495"></a>00495         }
<a name="l00496"></a>00496     }
<a name="l00497"></a>00497 }
</pre></div></div>
<!--- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&nbsp;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&nbsp;</span>Klasy</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&nbsp;</span>Przestrzenie nazw</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&nbsp;</span>Pliki</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&nbsp;</span>Funkcje</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&nbsp;</span>Zmienne</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&nbsp;</span>Wyliczenia</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&nbsp;</span>Właściwości</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&nbsp;</span>Zdarzenia</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr size="1"/><address style="text-align: right;"><small>Wygenerowano Mon Nov 9 06:08:18 2009 dla eCommerce programem&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>
</html>
